package org.jsbd.boss.action;

import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.jsbd.boss.common.DataGridModel;
import org.jsbd.boss.domian.statistics.RetentImsiUseCountVO;
import org.jsbd.boss.service.IRetentImsiUseCountService;
import org.jsbd.boss.util.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/retent/imsi/use/count")
public class RetentImsiUseCountController {

  private static final Logger logger = LoggerFactory.getLogger(RetentImsiUseCountController.class);

  @Autowired
  private IRetentImsiUseCountService retentImsiUseCountService;

  /**
   * 留存用户使用次数列表
   * @return
   */
  @RequestMapping(value = "/list")
  public String daylimit() {
    return "retentUseCount/list";
  }

  /**
   * 
   * 留存用户使用数据
   * @param model
   * @return
   */
  @RequestMapping(value = "/listJson", method = RequestMethod.POST)
  @ResponseBody
  public Map<String, Object> listJson(DataGridModel page, RetentImsiUseCountVO retentImsiUseCountVO) {
	  String startTime = retentImsiUseCountVO.getStartTime();
	  String endTime = retentImsiUseCountVO.getEndTime();
	  if (("-".equals(startTime) && "-".equals(endTime)) || (StringUtils.isBlank(startTime) && StringUtils.isBlank(endTime))) {
		  startTime = DateUtil.getCurrentDateFormatStr(DateUtil.DATE_PATTEN_YY_MM_DD);
		  retentImsiUseCountVO.setStartTime(startTime.substring(0, 7));
		  retentImsiUseCountVO.setEndTime("");
	  }
	  return retentImsiUseCountService.findListWithPage(page, retentImsiUseCountVO);
  }
  
}
